package com.ruoyi.rsikManage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rsikManage.domain.TVcrData;
import com.ruoyi.rsikManage.service.ITVcrDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * vcrController
 *
 * @author sxygsj
 * @date 2024-06-25
 */
@RestController
@RequestMapping("/rsikManage/vcr")
public class TVcrDataController extends BaseController
{
    @Autowired
    private ITVcrDataService tVcrDataService;

    /**
     * 查询vcr列表
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:vcr:list')")
    @GetMapping("/list")
    public TableDataInfo list(TVcrData tVcrData)
    {
        startPage();
        List<TVcrData> list = tVcrDataService.selectTVcrDataList(tVcrData);
        return getDataTable(list);
    }

    /**
     * 导出vcr列表
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:vcr:export')")
    @Log(title = "vcr", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TVcrData tVcrData)
    {
        List<TVcrData> list = tVcrDataService.selectTVcrDataList(tVcrData);
        ExcelUtil<TVcrData> util = new ExcelUtil<TVcrData>(TVcrData.class);
        util.exportExcel(response, list, "vcr数据");
    }

    /**
     * 获取vcr详细信息
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:vcr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tVcrDataService.selectTVcrDataById(id));
    }

    /**
     * 新增vcr
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:vcr:add')")
    @Log(title = "vcr", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TVcrData tVcrData)
    {
        return toAjax(tVcrDataService.insertTVcrData(tVcrData));
    }

    /**
     * 修改vcr
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:vcr:edit')")
    @Log(title = "vcr", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TVcrData tVcrData)
    {
        return toAjax(tVcrDataService.updateTVcrData(tVcrData));
    }

    /**
     * 删除vcr
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:vcr:remove')")
    @Log(title = "vcr", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tVcrDataService.deleteTVcrDataByIds(ids));
    }


    /**
     * 查询vcr列表
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:vcr:list')")
    @GetMapping("/getVcrByApeId")
    public TableDataInfo getVcrByApeId(String apeId)
    {

        List<TVcrData> list = tVcrDataService.getVcrByApeId(apeId);
        return getDataTable(list);
    }

}
